import {
    http,
    api,
    httpService
} from '@/common/http/index.js';
import qs from 'qs';

//查询门店商品入库信息
export const queryStoreGoodsStorageInfo = (params = {}) => {
    return http.post(api.queryStoreGoodsStorageInfo, qs.stringify(params), {
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    });
}
//查询所有的门店分组信息
export const queryStoreGrouping = (params = {}) => {
    return http.post(api.queryStoreGrouping, qs.stringify(params), {
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    });
}
//导入文件操作
//导入excel
export const uploadStoreGoodsStorageExcel = (params = {}) => {
    return http.post(api.uploadStoreGoodsStorageExcel, params, {
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    });
}
export const importReport = (file) => {
    let fd = new FormData();
    let promise = new Promise(function (resolve, reject) {
        var _token = localStorage.getItem('code') ? localStorage.getItem('code') : '';
        fd.append('accessToken', _token);
        fd.append('file', file);
        uploadStoreGoodsStorageExcel(fd).then(res => {
            resolve(res);
        }).catch(res => {
            reject(res);
        });
    })
    return promise;
};
//同步商品价格并推送
export const pullPricesAndReGenerate = (params = {}) => {
    return http.post(api.pullPricesAndReGenerate, qs.stringify(params), {
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    });
}
